您的訂閱是我製作影片的動力
訂閱點這裡~
影片程式碼(延續昨天)
#步驟一: na補值&相異點or離群值偵測
library(naniar)#前置1: chk NA
library(clustMixType)
any_na(data)
data_num <- data[,c(6,13:24)]
data_num <- as.data.frame(scale(data_num)) #前置2: standard norm 標準化
data_cla <- data[,c(2:5,7:12)]
data_cla <- lapply(data_cla, factor)
data_use <- cbind(data_num,data_cla)
kp <- kproto(data_use, 10)
kp_out <- as.data.frame(kp$cluster) #大好
final <- cbind(data,kp_out)
out <- final %>%
group_by(`kp$cluster`) %>%
summarise(筆數=n())
done <- final %>%
subset(`kp$cluster`!=10&`kp$cluster`!=6)
若內容有誤,還請留言指正,謝謝您的指教